<template>
  <div class="mr-mr-midSearch">
    <el-input
      style="width: 175px;margin-right: 5px;"
      ref="deleteInput"
      size="mini"
      v-model="deleteTiaoma"
      placeholder="请输入内容"
    ></el-input>
    <!-- <el-button size="mini" type="primary" @click="deleteBtn">撤销</el-button> -->
    <el-button size="mini" type="primary" @click="partReceiveBtn">接收</el-button>
    <!-- <el-button size="mini" type="primary" @click="partReceiveBackBtn">驳回</el-button> -->
    <!-- <el-button size="mini" type="primary" @click="partReturnAllSearch">零件接收明细</el-button> -->
    <ul>
      <li>
        <span>图号</span>
      </li>
      <li class="wewewe">
        <el-input
          size="mini"
          v-model="searchInfo.tuhao"
          placeholder="请输入内容"
           
        ></el-input>
      </li>
      <li>
        <span>质量编号</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="searchInfo.qualityNumber"
          placeholder="请输入内容"
           
        ></el-input>
      </li>
      <li>
        <span>移交人</span>
      </li>
      <li>
        <el-input
          size="mini"
          v-model="searchInfo.transferPerson"
          placeholder="请输入内容"
           
        ></el-input>
      </li>
      <li>
        <span>移交时间</span>
      </li>
      <li>
        <el-date-picker
          size="mini"
          v-model="searchInfo.startTime"
          type="date"
          placeholder="选择日期"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </li>
      <li>
        <span>到</span>
      </li>
      <li>
        <el-date-picker
          size="mini"
          v-model="searchInfo.endTime"
          type="date"
          placeholder="选择日期"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </li>
      <li>
        <el-button size="mini" type="primary" @click="scanningSearch">查询</el-button>
      </li>
    </ul>
  </div>
</template>
<script>
import { partFinSearch,bufferBoxOut,returnReceJieShou } from "@/utils/api.js";
export default {
  name: "MrmrMidSearch",
  watch: {
  },
  data() {
    return {
      // 查询条件
      searchInfo:{
        tuhao:'',
        qualityNumber:'',
        transferPerson:'',
        startTime:'',
        endTime:''
      },
      resData: "",
      totalCount: 1,
      // 拒绝表单样式
      formLabelWidth: "50px",
      pageSize:10,
      pageNumber:1,
      // 接收上表勾选信息
      topInfoList:[],
      // 接收下表的勾选数据列表
      selectList:[],
      // 归总接收数据的条码
      receiveDataList:[],
      // 归总所勾选的物料条码
      barcodeList:[],
      loginInfo:'',
      deleteTiaoma:'',
    };
  },
  methods: {
    // 退库接收-接收按钮
    partReceiveBtn(){
      // data传参数据拼接
      this.barcodeList.push(this.selectList[0].barcode)
      let hcxBoxInfoList = []
            let hcxData = ''
            for(let i=0;i<this.selectList.length;i++){
              hcxData = {'itemCode':this.selectList[i].itemCode,'deliveryQty':this.selectList[i].returnQty,
              'barcode':this.selectList[i].barcode,'wmsDeliveryPlanId':this.selectList[i].wmsDeliveryPlanId}
              hcxBoxInfoList.push(hcxData)
            }
      returnReceJieShou({
        barcode:this.selectList[0].barcode,
        returnQty:this.selectList[0].returnQty,
        wmsDeliveryPlanId:this.selectList[0].wmsDeliveryPlanId,
        status:'2',
        itemCode:this.selectList[0].itemCode,
        data:hcxBoxInfoList
      }).then((res)=>{
        console.log('退库接收接收接口',res)
        this.receiveDataList=this.barcodeList
        if(res.data.retCode == 200){
          this.$bus.$emit('refreshReturnReceTopTable','刷新退库上表')
          // 接收成功则把除该已经接收的数据的条码给下表进行删除并更新Table
          this.$bus.$emit('returnReceDeleteTiaoma',this.receiveDataList)
          // 假传参给首页 清空条码框 聚焦
          this.$bus.$emit('reReturnReceTmNull','')
          this.$bus.$emit('returnReceJdtSuccess','完成')
          this.$Alert({
            title: "成功",
            message: res.data.message,
            type: "success",
          })
        }else{
          this.$Alert({
            title: "失败",
            message: res.data.message,
            type: "error",
          })
        }
      })
    },
    // 退库接收-驳回按钮
    // partReceiveBackBtn(){
    //   returnReceJieShou({
    //     barcode:this.topInfoList[0].barcode,
    //     returnQty:this.topInfoList[0].returnQty,
    //     wmsDeliveryPlanId:this.topInfoList[0].wmsDeliveryPlanId,
    //     status:'3'
    //   }).then((res)=>{
    //     console.log('退库接收驳回接口',res)
    //     if(res.data.retCode == 200){
    //       this.$bus.$emit('refreshReturnReceTopTable','刷新退库上表')
    //       this.$Alert({
    //         title: "成功",
    //         message: res.data.message,
    //         type: "success",
    //       })
    //     }else{
    //       this.$Alert({
    //         title: "失败",
    //         message: res.data.message,
    //         type: "error",
    //       })
    //     }
    //   })
    // },
    //撤销按钮
    // deleteBtn(){
    //   for(let tr=0;tr<this.selectList.length;tr++){
    //     if(this.selectList[tr].barcode == this.deleteTiaoma){
    //       this.selectList.splice(tr,1)
    //     }
    //   }
    //   this.$bus.$emit('mrPrCxData',this.selectList)
    //   this.deleteTiaoma = ''
    //   this.$refs.deleteInput.focus()
    // },
    // 零件接收明细---统查条件查询
    // partReturnAllSearch(){
    //      partFinSearch({
    //       searchParams:{
    //       qualityCode:'',
    //       deliveryEmpCode:''
    //     },
    //     pageParameter:{
    //       rows:this.pageSize,
    //       page:1
    //     },
    //     startTime:'',
    //     endTime:'',                  
    //     drawNo:'',
    //   }).then((res) => {
    //     console.log('零件接收明细', res);
    //     this.$bus.$emit('returnReceSearchData',res.data.responseBody.result)
    //   });
    // },
    // 条件查询按钮
    scanningSearch() {
        partFinSearch({
          searchParams:{
          qualityCode:this.searchInfo.qualityNumber,
          deliveryEmpCode:this.searchInfo.transferPerson
        },
        pageParameter:{
          rows:this.pageSize,
          page:this.pageNumber 
        },
        startTime:this.searchInfo.startTime,
        endTime:this.searchInfo.endTime,                  
        drawNo:this.searchInfo.tuhao,
      }).then((res) => {
        console.log('零件接收条件查询', res);
        // this.resData = res.data.responseBody.result;
        // this.totalCount = res.data.responseBody.pageParameter.totalCount;
        this.$bus.$emit('returnReceSearchData',res.data.responseBody.result)
      });
    },
  },
  mounted(){
    // 接收Tables传的pageSize，pageNumber
    this.$bus.$on('returnRecePageNumbers',(e)=>{
      this.pageSize = e.pageSize,
      this.pageNumber = e.pageNumber
    })
    // 接收下表勾选的数据列表
    this.$bus.$on('returnReceSelectList',(e)=>{
      this.selectList = e
    })
    // 扫码接收Input回车调用接收按钮
    this.$bus.$on('mrReturnReceive',(e)=>{
      // 接收
      this.$options.methods.partReceiveBtn.bind(this)()
    })
    // 接收上表勾选的info
    this.$bus.$on('returnReceTtableCheak',(e)=>{
      this.topInfoList = e
      // console.log('接收勾选',e)
      // 接收勾选直接为接收接口组装参数

    })
  }
};
</script>
<style scoped>
/* .el-button--warning {
  background: #ee6d4f;
  border-color: #ee6d4f;
}
.el-button--warning:hover {
  background: #c25239;
  border-color: #c25239;
} */
.mr-mr-midSearch {
  overflow: hidden;
}
.mr-mr-midSearch ul li {
  height: 35px;
  float: left;
  margin-right: 10px;
  line-height: 35px;
}
.mr-mr-midSearch ul li .el-input {
  width: 175px;
}


</style>